function sendMessage() {
	var port = chrome.extension.connect({name: "memonaut"});
	var text = getText();
	if(text)
		port.postMessage({command: 'postMemo', selection: text });
	else
		port.postMessage({command: 'show'});
}

function getText() {
	var selection = window.getSelection();
	var text = selection ? selection.toString() : '';
	return text;
}

sendMessage();
